@extends('admin/layout/master')
@section('title', '用户列表')
@section('title2', '用户列表')

@section('static')
<script src="/plus/My97DatePicker/WdatePicker.js"></script>
@endsection

@section('action')
	<a class="layui-btn layui-btn-small layui-btn-normal usersAdd_btn" href="{{ url('/admin/user/create') }}"><i class="layui-icon"></i>用户添加</a>
	<!-- <a class="layui-btn layui-btn-small layui-btn-danger batchDel"><i class="layui-icon"></i>导出数据</a> -->
@endsection

@section('content')
<div class="layui-field-box layui-form">
  <form action="{{ url('/admin/user/index') }}" method="get">
    <div class="layui-form-item">
      <label class="layui-form-label">搜索：</label>
      <div class="layui-inline">
        <input type="text" name="username" placeholder="用户名" value="{{ $request->input('username') }}" autocomplete="off" class="layui-input">
      </div>
			<div class="layui-inline">
			  <input type="text" name="nickname" placeholder="昵称" value="{{ $request->input('nickname') }}" autocomplete="off" class="layui-input">
			</div>
			<div class="layui-inline">
			  <input type="text" name="time1" placeholder="最后登录时间" value="{{ $request->input('time1') }}" autocomplete="off" class="layui-input" onclick="WdatePicker({readOnly:true})">
			</div>
			<div class="layui-inline">
			  <input type="text" name="time2" placeholder="最后登录时间" value="{{ $request->input('time2') }}" autocomplete="off" class="layui-input" onclick="WdatePicker({readOnly:true})">
			</div>
      <!-- <div class="layui-inline" style="width: 150px;">
        <select name="channel" id="channel">
          <option value="">所属频道</option>
          <option value="1">普通文章</option>
          <option value="2">游戏下载</option>
        </select>
        <div class="layui-unselect layui-form-select">
          <div class="layui-select-title">
            <input type="text" placeholder="所属频道" value="" readonly="" class="layui-input layui-unselect">
            <i class="layui-edge"></i></div>
          <dl class="layui-anim layui-anim-upbit">
            <dd lay-value="1" class="">普通文章</dd>
            <dd lay-value="2" class="">游戏下载</dd>
          </dl>
        </div>
      </div>
      <div class="layui-inline" style="width: 150px;">
        <select name="typeid" id="typeid">
          <option value="">所属栏目</option>
          <option value="1">动作冒险</option>
          <option value="2">格斗对打</option>
          <option value="3">飞行射击</option>
          <option value="4">角色扮演</option>
          <option value="5">体育竞技</option>
          <option value="6">棋牌益智</option>
          <option value="7">模拟器</option>
          <option value="8">游戏资讯</option>
        </select>
        <div class="layui-unselect layui-form-select">
          <div class="layui-select-title">
            <input type="text" placeholder="所属栏目" value="" readonly="" class="layui-input layui-unselect">
            <i class="layui-edge"></i></div>
          <dl class="layui-anim layui-anim-upbit">
            <dd lay-value="1" class="">动作冒险</dd>
            <dd lay-value="2" class="">格斗对打</dd>
            <dd lay-value="3" class="">飞行射击</dd>
            <dd lay-value="4" class="">角色扮演</dd>
            <dd lay-value="5" class="">体育竞技</dd>
            <dd lay-value="6" class="">棋牌益智</dd>
            <dd lay-value="7" class="">模拟器</dd>
            <dd lay-value="8" class="">游戏资讯</dd>
          </dl>
        </div>
      </div>
      <div class="layui-inline" style="width: 70px;">
        <select name="isshow" id="isshow">
          <option value="">状态</option>
          <option value="1">正常</option>
          <option value="2">删除</option>
        </select>
        <div class="layui-unselect layui-form-select">
          <div class="layui-select-title">
            <input type="text" placeholder="状态" value="" readonly="" class="layui-input layui-unselect">
            <i class="layui-edge"></i></div>
          <dl class="layui-anim layui-anim-upbit">
            <dd lay-value="1" class="">正常</dd>
            <dd lay-value="2" class="">删除</dd>
          </dl>
        </div>
      </div> -->
      <button class="layui-btn"><i class="layui-icon"></i> </button>
      <a href="{{ url('/admin/user/index') }}" class="layui-btn layui-btn-primary">重置</a> </div>
  </form>
</div>
<div class="layui-field-box layui-form">
  <form name="mainform" method="post" action="{{ url('/admin/user/dels') }}">
    <table class="layui-table" lay-size="sm">
      <thead>
        <tr>
          <th style="width: 30px;"><input type="checkbox" lay-filter="allselector" lay-skin="primary" id="qx">
            <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div></th>
          <th>ID</th>
          <th>昵称</th>
          <th>用户名</th>
          <th>密码</th>
          <th>hash</th>
          <th>最后登录时间</th>
          <th>编辑</th>
        </tr>
      </thead>
      <tbody id="content">
		@foreach ($data as $v)
        <tr>
		<td>
			<input type="checkbox" name="ids[]" value="{{ $v->id }}" lay-skin="primary">
            <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div>
			</td>
			<td>{{ $v->id }}</td>
			<td><a href="/index/Archives/show/id/67" target="_blank">{{ $v->nickname }}</a></td>
			<td>{{ $v->username }}</td>
			<td>{{ $v->password }}</td>
			<td>{{ $v->hash }}</td>
			<td>{{ $v->lastlogin ? date('Y-m-d H:i', $v->lastlogin) : '未登录' }}</td>
			<td>
				<div class="layui-btn-group">
					<a href="{{ url('/admin/user/edit', array('id' => $v->id)) }}" class="layui-btn layui-btn-primary layui-btn-sm"> <i class="layui-icon">&#xe642;</i> </a>
					<a href="{{ url('/admin/user/destroy', array('id' => $v->id)) }}" onclick="return confirm('确定要删除吗？')" class="layui-btn layui-btn-primary layui-btn-sm"> <i class="layui-icon">&#xe640;</i> </a>
				</div>
			</td>
        </tr>
		@endforeach
		<tr>
			<td colspan="9" align="center" style="padding:20px 0px;">
				{{ $data->links() }}
				<div style="display: inline-block;padding-left: 0;">
					第<span class="pagelink_cur_page">{{ $data->currentPage() }}</span>/<span class="pagelink_all_page">{{ $data->lastPage() }}</span>页&nbsp;每页<span class="pagelink_pagesize">{{ $data->perPage() }}</span>条&nbsp;共<span class="pagelink_all_rec">{{ $data->total() }}</span>条 
				</div>
			</td>
		</tr>
        <tr>
			{{ csrf_field() }}
          <td colspan="9" align="center"><a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-mini" onclick="dels()">批量删除</a></td>
        </tr>
      </tbody>
    </table>
  </form>
</div>
@endsection

@section('layuijs')
<script>
//一般直接写在一个js文件中
layui.use(['layer', 'form'], function(){
  var layer = layui.layer
  ,form = layui.form;
	form.on('checkbox(allselector)', function(data){
      var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
      child.each(function(index, item){
          item.checked = data.elem.checked;
      });
      form.render('checkbox');
  });
});
</script>
<script>
//删除
function dels(){
	layer.confirm('是否批量删除?', {icon: 3, title:'提示'}, function(index){
		document.mainform.submit();
		layer.close(index);
	})
};
</script>
@endsection